package com.wandian.ui.controls
{
	import flash.display.*;
	import flash.events.*;
	
	public class ButtonStateAnimation extends Animation
	{
		private var fAlternativeAnimationId_int:int;
		private var fInUse_bl:Boolean;
		private var fAnimationType_str:String;
		protected var fCanInterrupt_bl_obj:Object;
		public static const BUTTON_ANIMATION_TYPE_IDLE:String = "idle";
		public static const BUTTON_ANIMATION_TYPE_DISABLE:String = "disable";
		public static const BUTTON_ANIMATION_TYPE_INTRO:String = "intro";
		public static const BUTTON_ANIMATION_TYPE_OVER:String = "over";
		public static const BUTTON_ANIMATION_TYPE_UP:String = "up";
		public static const BUTTON_ANIMATION_TYPE_DOWN:String = "down";
		
		public function ButtonStateAnimation(param1:MovieClip = null) : void
		{
			super(param1);
			this.alternativeId = 0;
			this.inUse = false;
			this.mouseEnabled = false;
			this.animationShell.mouseEnabled = false;
			return;
		}// end function
		
		protected function updateInterruptionVector(param1:Boolean, param2:Boolean, param3:Boolean, param4:Boolean, param5:Boolean, param6:Boolean) : void
		{
			this.interruptionVector[BUTTON_ANIMATION_TYPE_INTRO] = param1;
			this.interruptionVector[BUTTON_ANIMATION_TYPE_IDLE] = param2;
			this.interruptionVector[BUTTON_ANIMATION_TYPE_OVER] = param3;
			this.interruptionVector[BUTTON_ANIMATION_TYPE_DOWN] = param4;
			this.interruptionVector[BUTTON_ANIMATION_TYPE_UP] = param5;
			this.interruptionVector[BUTTON_ANIMATION_TYPE_DISABLE] = param6;
			return;
		}// end function
		
		public function get inUse() : Boolean
		{
			return this.fInUse_bl;
		}// end function
		
		protected function initInterruptionVectorByDefault() : void
		{
			switch(this.animationType)
			{
				case BUTTON_ANIMATION_TYPE_DISABLE:
				{
					this.updateInterruptionVector(false, true, true, false, false, false);
					break;
				}
				case BUTTON_ANIMATION_TYPE_DOWN:
				{
					this.updateInterruptionVector(false, true, true, true, true, false);
					break;
				}
				case BUTTON_ANIMATION_TYPE_IDLE:
				{
					this.updateInterruptionVector(false, true, false, false, false, false);
					break;
				}
				case BUTTON_ANIMATION_TYPE_INTRO:
				{
					this.updateInterruptionVector(true, true, true, true, true, true);
					break;
				}
				case BUTTON_ANIMATION_TYPE_OVER:
				{
					this.updateInterruptionVector(false, true, false, false, false, false);
					break;
				}
				case BUTTON_ANIMATION_TYPE_UP:
				{
					this.updateInterruptionVector(false, true, true, false, true, false);
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}// end function
		
		public function set inUse(param1:Boolean) : void
		{
			this.fInUse_bl = param1;
			return;
		}// end function
		
		public function set alternativeId(param1:int) : void
		{
			this.fAlternativeAnimationId_int = param1;
			return;
		}// end function
		
		override protected function onAnimationStarted(event:Event = null) : void
		{
			if (event)
			{
				if (this.nativeAnimationContent)
				{
					this.nativeAnimationContent.mouseEnabled = false;
				}
				this.nativeAnimation.mouseEnabled = false;
			}
			super.onAnimationStarted(event);
			return;
		}// end function
		
		protected function onAnimationTypeChanged() : void
		{
			this.initInterruptionVectorByDefault();
			return;
		}// end function
		
		protected function get interruptionVector() : Object
		{
			if (!this.fCanInterrupt_bl_obj)
			{
				this.fCanInterrupt_bl_obj = new Object();
			}
			return this.fCanInterrupt_bl_obj;
		}// end function
		
		public function canInterrupt(param1:String, param2:Boolean = false, param3:Boolean = false) : Boolean
		{
			if (param2)
			{
				this.interruptionVector[param1] = param3;
			}
			return this.interruptionVector[param1];
		}// end function
		
		public function set animationType(param1:String) : void
		{
			if (param1 == this.fAnimationType_str)
			{
				return;
			}
			this.fAnimationType_str = param1;
			this.onAnimationTypeChanged();
			return;
		}// end function
		
		public function get alternativeId() : int
		{
			return this.fAlternativeAnimationId_int;
		}// end function
		
		public function get animationType() : String
		{
			return this.fAnimationType_str;
		}// end function
		
	}
}
